# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xmlrpc-c
pkgver=1.51.07
pkgrel=1
pkgdesc="This library provides a modular implementation of XML-RPC for C and C++"
url="http://xmlrpc-c.sourceforge.net/"
arch="all"
license="BSD-3-Clause AND MIT"
depends_dev="libxml2-dev"
makedepends="libtool curl-dev libxml2-dev zlib-dev"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-client
	$pkgname-client++:clientxx
	xmlrpc-c++:cxx
	$pkgname-abyss
	$pkgname-tools
	"
source="$pkgname-$pkgver.tar::https://sourceforge.net/projects/xmlrpc-c/files/Xmlrpc-c%20Super%20Stable/$pkgver/xmlrpc-c-$pkgver.tgz/download"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--disable-libxml2-backend \
		--disable-cgi-server \
		--disable-libwww-client \
		--disable-wininet-client
	make -j1 AR=ar RANLIB=ranlib
	make -j1 AR=ar RANLIB=ranlib -C tools
}

package() {
	make AR=ar RANLIB=ranlib DESTDIR="$pkgdir" install
	make AR=ar RANLIB=ranlib DESTDIR="$pkgdir" install -C tools
	install -m 644 -D doc/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

tools() {
	pkgdesc="tools for xmlrpc-c"
	amove usr/bin
}

client() {
	pkgdesc="C client libraries for xmlrpc-c"
	replaces="$pkgname"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libxmlrpc_client.so.* "$subpkgdir"/usr/lib/
}

clientxx() {
	replaces="libxml-c++"
	pkgdesc="C++ client libraries for xmlrpc-c"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libxmlrpc_client++.so.* "$subpkgdir"/usr/lib/
}

cxx() {
	pkgdesc="This library provides a modular implementation of XML-RPC for C++"
	replaces="$pkgname"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*++* \
		"$pkgdir"/usr/lib/libxmlrpc_packetsocket.so.* \
		"$pkgdir"/usr/lib/libxmlrpc_cpp.so.* \
		"$subpkgdir"/usr/lib/
}

abyss() {
	pkgdesc="Abyss server libraries for C++"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*abyss* \
		"$subpkgdir"/usr/lib/
}

sha512sums="
f6c33cb67ea79f492a101cedd6337ce6f573c76d22c3d6f193d2f6aa974c753d53ea3a46fff8c4724bb24029f7e173e11e5deb2c931a55298a530a9000fb4620  xmlrpc-c-1.51.07.tar
"
